ArrayG.setClearFunc

Sets a function to clear an element of @array.

The @clear_func will be called when an element in the array data segment is removed and when the array is freed and data segment is deallocated as well. @clear_func will be passed a pointer to the element to clear, rather than the element itself.

Note that in contrast with other uses of #GDestroyNotify functions, @clear_func is expected to clear the contents of the array element it is given, but not free the element itself.

|[<!-- language="C" --> typedef struct { gchar *str; GObject *obj; } ArrayElement;

static void array_element_clear (ArrayElement *element) { g_clear_pointer (&element->str, g_free); g_clear_object (&element->obj); }

// main code GArray *garray = g_array_new (FALSE, FALSE, sizeof (ArrayElement)); g_array_set_clear_func (garray, (GDestroyNotify) array_element_clear); // assign data to the structure g_array_free (garray, TRUE); ]|

class ArrayG
void
setClearFunc

Parameters

clearFunc GDestroyNotify

a function to clear an element of @array

Meta

Since

2.32